/**
 * 
 */
package stc.skymobi.distributed.event;

import java.util.UUID;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import stc.skymobi.util.MutableIdentifyable;


/**
 * @author hp
 *
 */
public class UUIDLockResult implements MutableIdentifyable, LockResult {

	private	int			result = LOCK_ACQUIRED;
	private	String		resName = null;
	private	Throwable	exception = null;
	private	String		lockedId = null;
	
	private	UUID	id;
	
	public UUIDLockResult setLockedId(String lockedId) {
		this.lockedId = lockedId;
		return	this;
	}
	
	public UUIDLockResult setResName(String resName) {
		this.resName = resName;
		return	this;
	}
	
	public UUIDLockResult setException(Throwable e) {
		this.exception = e;
		return	this;
	}
	
	public UUIDLockResult setResult(int r) {
		this.result = r;
		return	this;
	}
	
	/* (non-Javadoc)
	 * @see com.skymobi.distributed.event.LockResult#getException()
	 */
	public Throwable getException() {
		return exception;
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.event.LockResult#getResourceName()
	 */
	public String getResourceName() {
		return resName;
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.event.LockResult#getResult()
	 */
	public int getResult() {
		return result;
	}

	public void setIdentification(UUID id) {
		this.id = UUID.fromString(id.toString());
	}

	public UUID getIdentification() {
		return UUID.fromString(id.toString());
	}

	public String getLockedId() {
		return lockedId;
	}

    public String toString() {
        
        return  ToStringBuilder.reflectionToString(this, 
                            ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
